.class Lcom/burstly/lib/util/calendar/Rfc3339Parser;
.super Ljava/lang/Object;
.source "Rfc3339Parser.java"


# static fields
.field private static final DATE_FORMATS:[Ljava/lang/String;

.field private static final RFC3339_PATTERN:Ljava/util/regex/Pattern;


# direct methods
.method static constructor <clinit>()V
    .locals 3

    .prologue
    .line 34
    const-string v0, "\\d{4}-\\d{2}-\\d{2}(T|\\s)\\d{2}:\\d{2}(:\\d{2}(\\.\\d{1,3}|)|)([\\+-]\\d{2}:\\d{2}|Z)"

    invoke-static {v0}, Ljava/util/regex/Pattern;->compile(Ljava/lang/String;)Ljava/util/regex/Pattern;

    move-result-object v0

    sput-object v0, Lcom/burstly/lib/util/calendar/Rfc3339Parser;->RFC3339_PATTERN:Ljava/util/regex/Pattern;

    .line 43
    const/16 v0, 0xa

    new-array v0, v0, [Ljava/lang/String;

    sput-object v0, Lcom/burstly/lib/util/calendar/Rfc3339Parser;->DATE_FORMATS:[Ljava/lang/String;

    .line 44
    sget-object v0, Lcom/burstly/lib/util/calendar/Rfc3339Parser;->DATE_FORMATS:[Ljava/lang/String;

    const/4 v1, 0x0

    const-string v2, "yyyy-mm-dd\'T\'HH:mmZ"

    aput-object v2, v0, v1

    .line 45
    sget-object v0, Lcom/burstly/lib/util/calendar/Rfc3339Parser;->DATE_FORMATS:[Ljava/lang/String;

    const/4 v1, 0x1

    const-string v2, "yyyy-mm-dd\' \'HH:mmZ"

    aput-object v2, v0, v1

    .line 46
    sget-object v0, Lcom/burstly/lib/util/calendar/Rfc3339Parser;->DATE_FORMATS:[Ljava/lang/String;

    const/4 v1, 0x2

    const-string v2, "yyyy-mm-dd\'T\'HH:mm:ssZ"

    aput-object v2, v0, v1

    .line 47
    sget-object v0, Lcom/burstly/lib/util/calendar/Rfc3339Parser;->DATE_FORMATS:[Ljava/lang/String;

    const/4 v1, 0x3

    const-string v2, "yyyy-mm-dd\' \'HH:mm:ssZ"

    aput-object v2, v0, v1

    .line 48
    sget-object v0, Lcom/burstly/lib/util/calendar/Rfc3339Parser;->DATE_FORMATS:[Ljava/lang/String;

    const/4 v1, 0x4

    const-string v2, "yyyy-mm-dd\'T\'HH:mm:ss.SZ"

    aput-object v2, v0, v1

    .line 49
    sget-object v0, Lcom/burstly/lib/util/calendar/Rfc3339Parser;->DATE_FORMATS:[Ljava/lang/String;

    const/4 v1, 0x5

    const-string v2, "yyyy-mm-dd\' \'HH:mm:ss.SZ"

    aput-object v2, v0, v1

    .line 50
    sget-object v0, Lcom/burstly/lib/util/calendar/Rfc3339Parser;->DATE_FORMATS:[Ljava/lang/String;

    const/4 v1, 0x6

    const-string v2, "yyyy-mm-dd\'T\'HH:mm:ss.SSZ"

    aput-object v2, v0, v1

    .line 51
    sget-object v0, Lcom/burstly/lib/util/calendar/Rfc3339Parser;->DATE_FORMATS:[Ljava/lang/String;

    const/4 v1, 0x7

    const-string v2, "yyyy-mm-dd\' \'HH:mm:ss.SSZ"

    aput-object v2, v0, v1

    .line 52
    sget-object v0, Lcom/burstly/lib/util/calendar/Rfc3339Parser;->DATE_FORMATS:[Ljava/lang/String;

    const/16 v1, 0x8

    const-string v2, "yyyy-mm-dd\'T\'HH:mm:ss.SSSZ"

    aput-object v2, v0, v1

    .line 53
    sget-object v0, Lcom/burstly/lib/util/calendar/Rfc3339Parser;->DATE_FORMATS:[Ljava/lang/String;

    const/16 v1, 0x9

    const-string v2, "yyyy-mm-dd\' \'HH:mm:ss.SSSZ"

    aput-object v2, v0, v1

    .line 55
    return-void
.end method

.method private constructor <init>()V
    .locals 0

    .prologue
    .line 60
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 61
    return-void
.end method

.method static parseDateString(Ljava/lang/String;)Ljava/util/Date;
    .locals 2
    .parameter "date"

    .prologue
    .line 70
    sget-object v1, Lcom/burstly/lib/util/calendar/Rfc3339Parser;->RFC3339_PATTERN:Ljava/util/regex/Pattern;

    invoke-virtual {v1, p0}, Ljava/util/regex/Pattern;->matcher(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;

    move-result-object v0

    .line 71
    .local v0, mtchr:Ljava/util/regex/Matcher;
    invoke-virtual {v0}, Ljava/util/regex/Matcher;->matches()Z

    move-result v1

    if-eqz v1, :cond_0

    .line 72
    invoke-static {p0}, Lcom/burstly/lib/util/calendar/Rfc3339Parser;->tryToParse(Ljava/lang/String;)Ljava/util/Date;

    move-result-object v1

    .line 74
    :goto_0
    return-object v1

    :cond_0
    const/4 v1, 0x0

    goto :goto_0
.end method

.method private static tryToParse(Ljava/lang/String;)Ljava/util/Date;
    .locals 11
    .parameter "date"

    .prologue
    .line 83
    new-instance v6, Ljava/lang/StringBuilder;

    invoke-direct {v6, p0}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    .line 84
    .local v6, sb:Ljava/lang/StringBuilder;
    invoke-virtual {v6}, Ljava/lang/StringBuilder;->length()I

    move-result v9

    add-int/lit8 v3, v9, -0x3

    .line 85
    .local v3, lastIndex:I
    const-string v9, ":"

    invoke-virtual {v6, v9}, Ljava/lang/StringBuilder;->lastIndexOf(Ljava/lang/String;)I

    move-result v9

    if-ne v9, v3, :cond_0

    .line 86
    invoke-virtual {v6, v3}, Ljava/lang/StringBuilder;->deleteCharAt(I)Ljava/lang/StringBuilder;

    .line 88
    :cond_0
    invoke-virtual {v6}, Ljava/lang/StringBuilder;->length()I

    move-result v9

    add-int/lit8 v8, v9, -0x1

    .line 89
    .local v8, zReplace:I
    const-string v9, "Z"

    invoke-virtual {v6, v9}, Ljava/lang/StringBuilder;->lastIndexOf(Ljava/lang/String;)I

    move-result v9

    if-ne v9, v8, :cond_1

    .line 90
    invoke-virtual {v6}, Ljava/lang/StringBuilder;->length()I

    move-result v9

    const-string v10, "+0000"

    invoke-virtual {v6, v8, v9, v10}, Ljava/lang/StringBuilder;->replace(IILjava/lang/String;)Ljava/lang/StringBuilder;

    .line 92
    :cond_1
    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    .line 93
    .local v1, dateString:Ljava/lang/String;
    new-instance v7, Ljava/text/SimpleDateFormat;

    invoke-direct {v7}, Ljava/text/SimpleDateFormat;-><init>()V

    .line 94
    .local v7, simpleDateFormat:Ljava/text/SimpleDateFormat;
    sget-object v0, Lcom/burstly/lib/util/calendar/Rfc3339Parser;->DATE_FORMATS:[Ljava/lang/String;

    .local v0, arr$:[Ljava/lang/String;
    array-length v4, v0

    .local v4, len$:I
    const/4 v2, 0x0

    .local v2, i$:I
    :goto_0
    if-ge v2, v4, :cond_2

    aget-object v5, v0, v2

    .line 96
    .local v5, pattern:Ljava/lang/String;
    :try_start_0
    invoke-virtual {v7, v5}, Ljava/text/SimpleDateFormat;->applyPattern(Ljava/lang/String;)V

    .line 97
    invoke-virtual {v7, v1}, Ljava/text/SimpleDateFormat;->parse(Ljava/lang/String;)Ljava/util/Date;
    :try_end_0
    .catch Ljava/text/ParseException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v9

    .line 103
    .end local v5           #pattern:Ljava/lang/String;
    :goto_1
    return-object v9

    .line 99
    .restart local v5       #pattern:Ljava/lang/String;
    :catch_0
    move-exception v9

    .line 94
    add-int/lit8 v2, v2, 0x1

    goto :goto_0

    .line 103
    .end local v5           #pattern:Ljava/lang/String;
    :cond_2
    const/4 v9, 0x0

    goto :goto_1
.end method
